package net.diaowen.common.base.controller;

//import net.diaowen.common.utils.dws2.DWSlicense;
//import net.diaowen.common.utils.dws2.Dwp;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static java.util.Locale.SIMPLIFIED_CHINESE;

@Controller
@RequestMapping("/user")
public class SecurityController {

    @Autowired
    @Qualifier("messageSource")
    private MessageSource messageSource;

    @RequestMapping("/logout.do")
    public String logout(HttpServletRequest request,HttpServletResponse response) throws Exception {
        System.out.println("............logout..................");
        if (SecurityUtils.getSubject() != null) {
            SecurityUtils.getSubject().logout();
        }
        request.getSession().invalidate();
        return "redirect:/login.jsp";
    }

    @RequestMapping("/login.do")
    public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {



        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/login");
        return modelAndView;
    }

}
